package furns.dao.impl;

import furns.dao.BasicDAO;
import furns.dao.MemberDAO;
import furns.entity.Member;

public class MemberDAOImpl extends BasicDAO<Member> implements MemberDAO {
    //通过用户名查询
    @Override
    public Member queryMemberByUsername(String username) {
        String sql = "select id,username,password,email,role from member where username = ?";
        return querySingle(sql,Member.class,username);
    }

    //注册用户
    @Override
    public int saveMember(Member member) {
        String sql = "insert into member(username,password,email) values(?,md5(?),?);";
        return  update(sql,member.getUsername(),member.getPassword(),member.getEmail());
    }

    @Override
    public Member queryMemberByUsernameAndPassword(String username,String password) {
        String sql = "select id,username,password,email,role from member where username = ? and password =  MD5(?)";
        return querySingle(sql,Member.class,username,password);
    }
}
